/*
 * Copyright (c) 2016- 2020 qolome.com Inc. All Rights Reserved.
 * ProjectName: qolome-knowledge
 * FileName: Calculator.java
 * Author: jiangfeng@qolome.com
 * Date: 2020/3/23 下午3:54
 * LastModified: 2020/03/23 15:54:23
 */

package com.qolome.knowledge.design.pattern.interpreter.calculator;

import com.qolome.knowledge.design.pattern.interpreter.calculator.util.OperatorUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Stack;

/**
 * @author Qolome
 * @version V1.0
 * @Description 计算器
 * @date 2020年 03月23日 15:54:44
 */
@Slf4j
public class QolomeCalculator {

    private Stack<IArithmeticInterpreter> stack = new Stack<>();


// TODO  未完成的计算器

    public QolomeCalculator(String expression){
    parse(expression);
    }

    private void parse(String expression) {

        String[] elements = expression.split(" ");;
        IArithmeticInterpreter left,right;

        for (int i = 0; i < elements.length; i++) {

            String element = elements[i];
            if (OperatorUtil.isOperator(elements[i])) {
                IArithmeticInterpreter push = stack.push(new NumberInterpreter(Integer.parseInt(element)));
                log.info("参数入栈:{}",push );
            }

        }

    }

    public int calulate(){
        return 0;
    }

}
